package com.os.util;

import cn.hutool.json.JSONUtil;

/**
 * 对象 和 byte 相互转换工具
 * @author zhaozhikai
 * @date 2023/8/6 20:22
 */
public class ByteConvertUtil {

    public static byte[] toByte(Object obj){
       return JSONUtil.toJsonPrettyStr(obj).getBytes();
    }

    public static Object toObj(byte[] bytes, Class T){
        String s = new String(bytes);
        Object o = JSONUtil.toBean(s, T);
        return o;
    }

}
